package com.example.sfm.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.sfm.constant.MessageConstants;
import com.example.sfm.pojo.dto.ClassesQueryDto;
import com.example.sfm.pojo.entity.Classes;
import com.example.sfm.pojo.vo.ClassesVo;
import com.example.sfm.result.PageResult;
import com.example.sfm.result.Result;
import com.example.sfm.service.IClassesService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sfm
 * @since 2025-03-09
 */
@RestController("userClassesController")
@RequestMapping("/user/classes")
@RequiredArgsConstructor
@Slf4j
@Tag(name = "用户班级相关接口", description = "用户班级相关接口")
public class ClassesController {

    private final IClassesService classesService;

    /**
     * 分页查询班级，支持条件查询
     *
     * @param queryDto 查询条件
     * @return 分页班级列表
     */
    @GetMapping("/list")
    @Operation(summary = "分页查询班级", description = "根据查询条件分页查询班级列表")
    public Result<PageResult<ClassesVo>> listClasses(@Validated @ParameterObject ClassesQueryDto queryDto) {
        log.info("分页查询班级: {}", queryDto);
        Page<Classes> page = new Page<>(queryDto.getPageNum(), queryDto.getPageSize());
        return Result.success(classesService.listClasses(page, queryDto), MessageConstants.SELECT_OK);
    }
}
